home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / gfx / xanimami.lha / XanimAmigaBeta7 / xanim_egs.c < prev    next >
C/C++ Source or Header  |  1995-04-16  |  3KB  |  150 lines

  1. /*
  2.    Initialisation file for EGS
  3.    Compiled and tested
  4.  
  5.    Author: Oliver Eichhorn
  6. */
  7.  
  8. #include <string.h>
  9. #include <stdlib.h>
  10. /*#include <proto/exec.h>*/
  11.  
  12. #include <egs/egs.h>
  13. #include <egs/egsrequest.h>
  14. #include <egs/egsblit.h>
  15. #include <egs/proto/egs.h>
  16. #include <egs/proto/egsrequest.h>
  17. #include <egs/proto/egsblit.h>
  18.  
  19.  
  20. struct E_EScreen *pEgsScreen = NULL;
  21. struct Library  *EGSBase = NULL;
  22. struct Library  *EGSRequestBase = NULL;
  23. struct Library  *EGSBlitBase = NULL;
  24.  
  25. /* i didnt find memstart in your merlin file, so here there's mine */
  26. UBYTE *memstart;
  27.  
  28. /* The following stuff is for screenmode requester.
  29.    If you have the old EGS V5 includes (like me)
  30.    you will need this */
  31. /*
  32.    typedef struct ER_ScrModeRequest *ER_ScrModeReqPtr;
  33.  
  34.    struct ER_ScrModeRequest
  35.     {
  36.      struct ER_Request  Req;
  37.      APTR                Reserved1;
  38.      APTR                Reserved2;
  39.      char                *ScreenMode;
  40.      short               Width;
  41.      short               Height;
  42.      long                Depths;
  43.      short               Depth;
  44.     };
  45.  
  46.    #pragma libcall EGSRequestBase ER_CreateScrModeReq 6C 801
  47.    ER_ScrModeReqPtr ER_CreateScrModeReq(ER_ReqContextPtr con);
  48.  
  49. */
  50.  
  51. void CloseEGS()
  52.  {
  53.   if (pEgsScreen)        E_CloseScreen(pEgsScreen);
  54.   if (EGSBase)           CloseLibrary(EGSBase);
  55.   if (EGSRequestBase)    CloseLibrary(EGSRequestBase);
  56.   if (EGSBlitBase)       CloseLibrary(EGSBlitBase);
  57.  }
  58.  
  59.  
  60. void OpenEGS()
  61.  {
  62.   struct ER_ReqContext      *myReqContext = NULL;
  63.   struct ER_ScrModeRequest  *myScrModeReq = NULL;
  64.   struct E_NewEScreen       myNewEScreen;
  65.  
  66.   /* open egs libraries */
  67.  
  68.   EGSBase = OpenLibrary("egs.library", 6L);
  69.  
  70.   if (!EGSBase)
  71.    {
  72.     CloseEGS();
  73.     exit(20);
  74.    }
  75.  
  76.   EGSRequestBase = OpenLibrary("egsrequest.library", 6L);
  77.  
  78.   if (!EGSRequestBase)
  79.    {
  80.     CloseEGS();
  81.     exit(20);
  82.    }
  83.  
  84.   EGSBlitBase = OpenLibrary("egsblit.library", 6L);
  85.  
  86.   if (!EGSBlitBase)
  87.    {
  88.     CloseEGS();
  89.     exit(20);
  90.    }
  91.  
  92.   /* create screenmode requester */
  93.  
  94.   myReqContext = ER_CreateReqContext();
  95.  
  96.   if (!myReqContext)
  97.    {
  98.     CloseEGS();
  99.     exit(20);
  100.    }
  101.  
  102.   myScrModeReq = ER_CreateScrModeReq(myReqContext);
  103.  
  104.   if (!myScrModeReq)
  105.    {
  106.     ER_DeleteReqContext(myReqContext);
  107.     CloseEGS();
  108.     exit(20);
  109.    }
  110.  
  111.   /* open screenmode requester to ask user for screenmode */
  112.  
  113.   if (!ER_DoRequest((ER_RequestPtr)myScrModeReq))
  114.    {
  115.     ER_DeleteRequest((ER_RequestPtr)myScrModeReq);
  116.     ER_DeleteReqContext(myReqContext);
  117.     CloseEGS();
  118.     exit(20);
  119.    }
  120.  
  121.   /* put together newscreen */
  122.  
  123.   myNewEScreen.Mode       = myScrModeReq->ScreenMode;
  124.   myNewEScreen.Depth      = myScrModeReq->Depth;
  125.   myNewEScreen.Colors     = NULL;
  126.   myNewEScreen.Map        = NULL;
  127.   myNewEScreen.Flags      = 0L;
  128.   myNewEScreen.Mouse      = NULL;
  129.   myNewEScreen.EdcmpFlags = 0L;
  130.   myNewEScreen.Port       = NULL;
  131.  
  132.   /* open screen */
  133.  
  134.   pEgsScreen = E_OpenScreen(&myNewEScreen);
  135.  
  136.   ER_DeleteRequest(&myScrModeReq->Req);
  137.   ER_DeleteReqContext(myReqContext);
  138.  
  139.   if (!pEgsScreen)
  140.    {
  141.     CloseEGS();
  142.     exit(20);
  143.    }
  144.  
  145.   /* lock the screen bitmap, because it must not be swapped */
  146.  
  147.   pEgsScreen->Map->Typekey.PixelMap.Planes.Lock++;
  148.   memstart = pEgsScreen->Map->Typekey.PixelMap.Planes.Dest;
  149.  }
  150.